home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u304.dms / in.adf / bits / Requesters.Acc / Requesters.amosSourceCode
Encoding:
AMOS Source Code  |  1992-03-22  |  5.4 KB  |  155 lines

  1. ' Put the following 2 lines at the beginning of your program!  
  2. Dim T$(10)
  3. Global T$(),Z,OLDCL,CL
  4.  
  5. ' Requester procedures by James Lanng for the AMOS PD library.  Feel free to 
  6. ' use them within your own programs. 
  7.  
  8. ' REQ is a procedure to make a standard requester open in the centre of the
  9. ' screen.  T1$ contains the first line of the title, and T2$ is the second 
  10. ' line of the title.  If T2$ is empty, i.e. "" then T1$ is moved into the
  11. ' centre.  B1$ and B2$ are the buttons, if B2$ is empty, the first button
  12. ' expands over where B2$ would be. 
  13. ' The variable Z equals either 1 or 2, corresponding to the button clicked 
  14. ' on.
  15.  
  16. ' NREQ is a requester which fills the whole screen, and can have 7 items in  
  17. ' NTSC mode (USA), or 10 in PAL mode (Europe & Australasia).  To set up the
  18. ' items, first call the CLRT procedure, then set up the items as below:
  19. '
  20. ' CLRT 
  21. ' T$(1)="First item" 
  22. ' T$(2)="Second item"
  23. '
  24. ' All the buttons that are empty have no border drawn around them. 
  25. '  
  26. ' NM is the number of items there are.   
  27. '
  28. ' CL contains 0 if the screen is to be closed when a button has been selected, 
  29. ' or 1 if the screen is to be kept open. 
  30.  
  31. Procedure REQ[T1$,T2$,B1$,B2$]
  32.    Show 
  33.    Flash Off 
  34.    Paper 0 : Cls : Curs Off 
  35.    Palette 0,$444,$777,$FFF
  36.    Reserve Zone 3
  37.    L1=Len(T1$) : L2=Len(T2$) : B1=Len(B1$) : B2=Len(B2$)
  38.    If L1>0 and L1<33 Then T1$=Space$((33-L1)/2)+T1$+Space$((33-L1)/2)+" "
  39.    If L2>0 and L2<33 Then T2$=Space$((33-L2)/2)+T2$+Space$((33-L2)/2)+" "
  40.    Z=(28-B1)/2
  41.    If B1>0 and B1<28 and B2=0 Then B1$=Space$(Z)+B1$+Space$(Z) : Goto UHUH
  42.    If B1>0 and B1<8 Then B1$=Space$((8-B1)/2)+B1$+Space$((8-B1)/2)
  43.    UHUH:
  44.    If B2>0 and B2<8 Then B2$=Space$((8-B2)/2)+B2$+Space$((8-B2)/2)
  45.    If Len(T1$)>33 Then T1$=Left$(T1$,33)
  46.    If Len(T2$)>33 Then T2$=Left$(T2$,33)
  47.    If Len(B1$)>0 and B2=0 Then Goto ARHA
  48.    If Len(B2$)>8 Then B2$=Left$(B2$,8)
  49.    ARHA:
  50.    If Len(B1$)>28 and Len(B2$)=0 Then B1$=Left$(B1$,28)
  51.    If B2>8 Then B2$=Left$(B2$,8)
  52.    Ink 1 : Bar 170,0 To 470,52
  53.    Ink 3 : Bar 171,1 To 470,59
  54.    Ink 2 : Bar 171,1 To 468,58
  55.    Ink 0 : Bar 180,10 To 458,30
  56.    Ink 3 : Draw 180,30 To 458,30 : Draw 458,30 To 458,10
  57.    RDRAW:
  58.    If Len(B1$)>0 and Len(B2$)=0
  59.       Ink 3 : Box 200,37 To 430,52
  60.       Ink 0 : Draw 200,52 To 430,52 : Draw 430,52 To 430,37
  61.       Ink 0,2
  62.       Text 204,47,B1$
  63.       Set Zone 3,200,37 To 430,52
  64.       Goto HULLO
  65.    End If 
  66.    If Len(B1$)>0
  67.       Ink 3 : Box 200,37 To 270,52
  68.       Ink 0 : Draw 200,52 To 270,52 : Draw 270,52 To 270,37
  69.    End If 
  70.    If Len(B2$)>0
  71.       Ink 3 : Box 360,37 To 430,52
  72.       Ink 0 : Draw 360,52 To 430,52 : Draw 430,52 To 430,37
  73.    End If 
  74.    Ink 0,2
  75.    Text 204,47,B1$
  76.    HULLO:
  77.    If T2$<>"" Then Text 187,18,T1$ : Else Text 187,22,T1$
  78.    Text 187,26,T2$
  79.    Text 364,47,B2$
  80.    If Len(B1$)>0 Then Set Zone 1,200,37 To 270,52
  81.    If Len(B2$)>0 Then Set Zone 2,360,37 To 430,52
  82.    If Len(B1$)>0 and Len(B2$)=0 Then Set Zone 1,0,0 To 1,1 : Set Zone 2,0,0 To 1,1
  83.    Do 
  84.       Z=Mouse Zone
  85.       M=Mouse Key
  86.       If Z=1 and M<>0 Then Ink 0 : Box 200,37 To 270,52 : Ink 3 : Draw 200,52 To 270,52 : Draw 270,52 To 270,37 : Repeat : Until Mouse Key=0 : If Mouse Zone<>1 Then Goto RDRAW : Else Screen Close 7 : Limit Mouse 128,42 To 447,297 : Pop Proc
  87.       If Z=2 and M<>0 Then Ink 0 : Box 360,37 To 430,52 : Ink 3 : Draw 360,52 To 430,52 : Draw 430,52 To 430,37 : Repeat : Until Mouse Key=0 : If Mouse Zone<>2 Then Goto RDRAW : Else Screen Close 7 : Limit Mouse 128,42 To 447,297 : Pop Proc
  88.       If Z=3 and M<>0 Then Ink 0 : Box 200,37 To 430,52 : Ink 3 : Draw 200,52 To 430,52 : Draw 430,52 To 430,37 : Repeat : Until Mouse Key=0 : If Mouse Zone<>3 Then Goto RDRAW : Else Screen Close 7 : Limit Mouse 128,42 To 447,297 : Pop Proc
  89.       LP:
  90.    Loop 
  91. End Proc
  92. Procedure NREQ[TI$,NM,CL]
  93.    If OLDCL=1 Then Goto DN
  94.    If Ntsc=0 Then Screen Open 7,640,240,4,Hires : Else Screen Open 7,640,200,4,Hires
  95.    If Ntsc=1 and NM>7 Then NM=7
  96.    Show 
  97.    Flash Off 
  98.    Paper 0 : Cls 2 : Curs Off 
  99.    Palette 0,$555,$888,$FFF
  100.    DN:
  101.    Reserve Zone NM
  102.    For A=1 To NM
  103.       If T$(A)="" Then Add ZZ,1 : Else Exit 
  104.    Next A
  105.    If Ntsc=0 Then Limit Mouse 178,90+(ZZ*20) To 398,90+NM*20-8 : Else Limit Mouse 178,90+(ZZ*20) To 398,90+NM*20-8
  106.    Cls 2
  107.    Paper 2
  108.    If Ntsc=0 Then Locate 0,29 : Else Locate 0,24
  109.    Pen 0
  110.    Centre "APE NREQ procedure by James Lanng for AMOS PD"
  111.    Ink 0
  112.    If Ntsc=0 Then Box 4,1 To 635,228 : Else Box 4,1 To 635,188
  113.    A=27-(Len(TI$)/2)+1
  114.    TI$=Space$(A)+TI$
  115.    For A=1 To NM
  116.       If T$(A)="" Then Goto NX
  117.       B=25-(Len(T$(A))/2)
  118.       T$(A)=Space$(B)+T$(A)
  119.       NX:
  120.    Next A
  121.    Ink 1
  122.    Box 80,10 To 560,10+12
  123.    Ink 3
  124.    Draw 80,10 To 560,10
  125.    Draw 560,10 To 560,22
  126.    Ink 1,2
  127.    Text 85,10+9,TI$
  128.    RDRAW:
  129.    For A=1 To NM
  130.       If T$(A)="" Then Goto NXT
  131.       Ink 1
  132.       Box 100,A*20+20 To 540,A*20+20+12
  133.       Ink 3
  134.       Draw 100,A*20+20 To 540,A*20+20
  135.       Draw 540,A*20+20 To 540,A*20+20+12
  136.       Ink 1,2
  137.       Text 105,A*20+20+9,T$(A)
  138.       Set Zone A,100,A*20+20 To 540,A*20+20+12
  139.       NXT:
  140.    Next A
  141.    LOP:
  142.    Repeat : Until Mouse Click
  143.    Z=Mouse Zone
  144.    If Z=0 Then Goto LOP : Else Ink 3 : Box 100,Z*20+20 To 540,Z*20+20+12 : Ink 1 : Draw 100,Z*20+20 To 540,Z*20+20 : Draw 540,Z*20+20 To 540,Z*20+20+12 : Repeat : Until Mouse Key=0 : If Mouse Zone<>Z Then Goto RDRAW : Else FSH : Pop Proc
  145. End Proc
  146. Procedure CLRT
  147.    For A=1 To 10
  148.       T$(A)=""
  149.    Next A
  150. End Proc
  151. Procedure FSH
  152.    OLDCL=CL
  153.    If CL=0 Then Screen Close 7
  154.    If CL=1 Then Rem Don't Screen Close 7 
  155. End Proc